# -*- coding: utf-8 -*-
"""
Created on Thu Mar 19 14:48:04 2020

@author: Administrator
"""

# 导入selenium2中的webdriver库
from selenium import webdriver
import selenium
# 实例化出一个Firefox浏览器 
#driver = webdriver.Chrome()
driver = webdriver.Chrome('C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe')
#driver = webdriver.Firefox('C:/Program Files/Mozilla Firefox/geckodriver.exe')#这里是火狐的浏览器运行方法
# 设置浏览器窗口的位置和大小
driver.set_window_position(20,40)
driver.set_window_size(1100,700)
driver.get("http://srm.lbxdrugs.com:6066/srm/coframe/auth/login/login.jsp")
driver.delete_all_cookes()
print(driver.get_cookies())
driver.add_cookie({'domain': '.lbxdrugs.com', 'expiry': 1650599432, 'httpOnly': False, 'name': 'NTKF_T2D_CLIENTID', 'path': '/', 'secure': False, 'value': 'guest13CB8344-3129-CD07-63A2-A0023837D9AE'}, {'domain': '.lbxdrugs.com', 'httpOnly': False, 'name': 'nTalk_CACHE_DATA', 'path': '/', 'secure': False, 'value': '{uid:kf_9749_ISME9754_guest13CB8344-3129-CD,tid:1587527432247416}'}, {'domain': 'srm.lbxdrugs.com', 'httpOnly': True, 'name': 'JSESSIONID', 'path': '/srm/', 'secure': False, 'value': 'FD1E7BF58C1D423AC62735FF5F51FE27'})
print(driver.get_cookies())
driver.delete_all_cookies()
print(driver.get_cookies())

# 打开一个页面
driver.get("http://srm.nepstar.cn/ELSServer_HWXC/default2.jsp?account=110829_1001&loginChage=N&telphone1=18279409642")

# 登录表单在页面的框架中中，所以要切换到该框架
#driver.switch_to_frame('login_frame')

# 通过使用选择器选择到表单元素进行模拟输入和点击按钮提交
#driver.find_element_by_id('switcher_plogin').click()
driver.find_element_by_id('elsAccount').clear()
driver.find_element_by_id('elsAccount').send_keys('110829')
driver.find_element_by_id('elsSubAccountPassword').clear()
driver.find_element_by_id('elsSubAccountPassword').send_keys('zz3737')#password
driver.find_element_by_id('submit_btn').click()

# do something

# 退出窗口
driver.quit()